<template>
  <ul class="cardStyle">
    <li class="table-head">
      <span v-for="item in tableColumns" :key="item.key" :class="[item.scopedSlots ? `flex-span${item.scopedSlots}` : '', `${item?.className}`]">
        {{ item.title }}
      </span>
    </li>
    <!-- () => props.num -->
    <div class="table-head-scroll">
      <Vue3SeamlessScroll
        :list="dataList"
        :singleWaitTime="props.waitTime"
        :hover="true"
        :singleHeight="80"
        :singleLine="true"
        :visibleCount="props.num"
      >
        <li v-for="(item, index) in dataList" :key="keys || index">
          <span
            type="click"
            :itemData="JSON.stringify(item)"
            v-for="item1 in tableColumns"
            :key="item1.key"
            :class="[item1.className, item1.scopedSlots ? `flex-span${item1.scopedSlots}` : '']"
          >
            <slot :name="item1.key" :data="item[item1['key']]" :itemData="JSON.stringify(item)" :index="index">{{ item[item1['key']] || '--' }}</slot>
          </span>
        </li>
      </Vue3SeamlessScroll>
    </div>
  </ul>
</template>
<script lang="ts" name="table-scroll" setup>
  import { computed, PropType, ComputedGetter } from 'vue';
  import { Vue3SeamlessScroll } from 'vue3-seamless-scroll';
  //#region 模拟
  // const tableColumnsWarning = [
  //   {
  //     title: '时间',
  //     key: 'sj',
  //     scopedSlots: 2 // 所占宽度
  //   },
  //   {
  //     title: '类型',
  //     key: 'lx',
  //     scopedSlots: 1
  //   },
  //   {
  //     title: '地址',
  //     key: 'dz',
  //     scopedSlots: 3
  //   },
  //   {
  //     title: '事件',
  //     key: 'sjxq',
  //     scopedSlots: 2
  //   },
  //   {
  //     title: '操作',
  //     key: 'cz'
  //   }
  // ]
  //#endregion

  const props = defineProps({
    info: {
      type: Array as PropType<any[]>,
      default: () => {
        return [];
      },
    },
    loading: {
      type: Boolean,
      default: false,
    },
    tableColumns: {
      type: Array as PropType<any[]>,
      default: () => {
        return [];
      },
    },
    keys: {
      type: String || Number,
      default: '',
    },
    num: { type: Number, default: 2 },
    waitTime: {
      type: Number,
      default: 2300,
    },
  });

  // const scrollOption = computed(() => {
  //   return {
  //     step: 1,
  //     hoverStop: true,
  //     limitMoveNum: props.num,
  //     singleHeight: 34,
  //     waitTime: 2300,
  //   };
  // });
  const dataList = computed(() => {
    return props.info as ComputedGetter<Array<unknown>>;
  });
</script>
<style lang="less" scoped>
  .text-left {
    text-align: left !important;
  }
  .text-center {
    text-align: center !important;
  }
  .cardStyle {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  .table-head-scroll {
    height: calc(100% - 48px) !important;
    overflow: hidden;
  }
  :deep(.vue3-seamless-wrapper) {
  }
  ul {
    height: 100%;
    padding: 0;
    margin: 0;

    li {
      padding: 0;
      list-style: none;
      font-size: 12px;
      line-height: 80px;
      display: flex;
      align-content: space-between;
      justify-content: left;
      align-items: center;
      border-bottom: 1px solid rgba(42, 69, 93, 1);
      width: 100%;
      > span {
        flex: 1;
        display: inline-block;
        // display: -webkit-box;
        // display: -webkit-box-flex;
        color: #fff;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 400;
        font-size: 18px;
        // -webkit-line-clamp: 1;
        // -webkit-box-orient: vertical;
      }
      > span.flex-span {
        display: flex;
        flex-direction: row;
      }
      > span.flex-span2 {
        flex: 2;
      }
      > span.flex-span3 {
        flex: 3;
      }
      > span.flex-span4 {
        flex: 4;
      }
      // > span:last-child {
      //   text-align: right;
      // }
    }
    // li:not(.table-head):nth-child(even) {
    //   line-height: 22px;
    //   margin-bottom: 3px;
    //   background: transparent;
    //   border-radius: 2px;
    //   border: 1px solid transparent;
    //   background-clip: content-box;
    //   border-image: linear-gradient(90deg, rgba(116, 112, 172, 0), rgba(116, 112, 172, 1)) 1 1;
    //   //   cursor: pointer;
    // }
    // li:not(.table-head):nth-child(odd) {
    //   line-height: 22px;
    //   margin-bottom: 3px;
    //   background: linear-gradient(270deg, rgba(39, 125, 255, 0.31) 67%, rgba(39, 125, 255, 0) 100%);
    //   border-radius: 2px;
    //   border: 1px solid transparent;
    //   background-clip: content-box;
    //   border-image: linear-gradient(90deg, rgba(116, 112, 172, 0), rgba(116, 112, 172, 1)) 1 1;
    //   // cursor: pointer;
    // }
    // li:not(.table-head):not(.table-head):nth-child(0) {
    //   text-align: left;
    // }

    .table-head {
      background: rgba(3, 23, 51, 1) !important;
      // padding: 4px 0 4px;

      > span {
        font-weight: 500;
        font-size: 18px;
        background: rgba(3, 23, 51, 1) !important;
        color: #ffffff;
        line-height: 48px;
        text-align: left;
        text-align: center;
      }
    }
  }
</style>
